package top.wenzz.manage.system.manage.web;

import org.springframework.web.bind.annotation.*;
import top.wenzz.manage.system.manage.entity.SysUser;
import top.wenzz.manage.system.manage.service.SysUserService;
import top.wenzz.commons.utils.ExceptionUtils;
import top.wenzz.commons.web.BasicCrudController;

/**
 * 系统用户controller
 * Created by 钟廷员 on 2016/12/15.
 */
@RestController
@RequestMapping("sys/user")
public class SysUserController extends BasicCrudController<SysUser, SysUserService> {
    @RequestMapping( value = "updatePassword", method = RequestMethod.POST )
    public Object updatePassword(@RequestBody SysUser entity) {
        String ret;
        try {
            ret = service.updatePassword(entity);
        } catch (Exception e) {
            ret = ExceptionUtils.getExceptionMsg(e);
        }
        return ret(ret, "修改密码成功");
    }

    @RequestMapping( value = "shotOff", method = RequestMethod.POST )
    public Object shotOff(String username) {
        String ret;
        try {
            ret = service.shotOff(username);
        } catch (Exception e) {
            ret = ExceptionUtils.getExceptionMsg(e);
        }
        return ret(ret, "下线成功");
    }
}
